if (!jsx3.lang.Class.forName("tibco.admin.enterpriseAssets.userMgt.user.SuperUserList")) {
jsx3.require("jsx3.gui.Dialog");

    /**
	 * Extension of the <code>jsx3.gui.Dialog</code> class, the super user list.
	 */
    jsx3.lang.Class.defineClass("tibco.admin.enterpriseAssets.userMgt.user.SuperUserList",
            jsx3.gui.Dialog,
            null,
            function (superUserList) {

                var valutemplate = '<xsl:template xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><span style="width:100%; height:100%; font-weight:bold"> <xsl:value-of select="{0}"/> </span>  </xsl:template>'
				
				/**
				 * instance initializer
				 */
                superUserList.prototype.initialize = function() {

                    // set the window instance id
                    /*
                    if (jsx3.lang.Class.forName("tibco.admin.enterpriseAssets.userMgt.window.Window")) {
                        this.window = this.getAncestorOfType(tibco.admin.enterpriseAssets.userMgt.window.Window)
                        if (this.window) {
                            this.setWindowId(this.window.getId());
                        }
                    }
                    */
					var me = this;
					this.mtx = this.getDescendantOfName("mtxSuperUserList_24_N");
					this.mtx.callremoveSuperUsers = function(curRowId){
						me.callremoveSuperUsers(curRowId);
					}
                }

                superUserList.prototype.setWindow = function(window) {
                    this.window = window
                    this.setWindowId(this.window.getId());
                    this.loadSubComponent("blkAddSuperUser_24_N", "tibco/admin/enterpriseAssets/userMgt/window/user/ui/superUserSearchbar.xml");
					this.callgetSuperUsers();
                }

                /**
				 *   set the current window ID
				 *   @para strId {string} The window id
				 */
                superUserList.prototype.setWindowId = function(strId) {
                    this.windowId = strId;
                }

                /**
				 *   get the current window ID
				 *   @return {string} The window id
				 */
                superUserList.prototype.getWindowId = function() {
                    return this.windowId;
                }               

                superUserList.prototype.subscribeAll = function() {
					tibco.admin.PubSub.subscribe(tibco.admin.enterpriseAssets.userMgt.EventID.ADD_ITEM_SUCCESS, this, this.callgetSuperUsers);
                }

                superUserList.prototype.unsubscribeAll = function() {
					tibco.admin.PubSub.unsubscribe(tibco.admin.enterpriseAssets.userMgt.EventID.ADD_ITEM_SUCCESS, this);
                }
				
				/**
				 * Load sub component
				 * @para nodeName {string} The parent node of the sub component
				 * @para path {string} The path of the sub component
				 */
                superUserList.prototype.loadSubComponent = function(nodeName, path) {
                    var domeNode = this.getDescendantOfName(nodeName);
                    // Load only if dose not exists
                    if (domeNode.getChildren().length == 0) {
                        tibco.admin.Main.loadUIResourceAsync(domeNode, "tibco.admin", path, this, this.isLoaded, true, true);
                    }
                }
				
				/**
				 *  The callback function of loadSubComponent
				 */
                superUserList.prototype.isLoaded = function(msg) {
                   msg.obj.setWindow(this.window);
                }

                //============== get super users list ==============================
				/**
				 *	  Get super users - webservice call
				 */
				superUserList.prototype.callgetSuperUsers = function() {
				  var objService = tibco.admin.Main.loadService("tibco.admin", "tibco/admin/enterpriseAssets/userMgt/window/user/rules/getSuperUsers.xml", "getSuperUsers", "Get Super Users");
				  objService.subscribe(jsx3.net.Service.ON_SUCCESS, this,this.ongetSuperUsersSuccess);
				  //objService.subscribe(jsx3.net.Service.ON_ERROR, this,this.ongetSuperUsersError);
				  //objService.subscribe(jsx3.net.Service.ON_INVALID, this,this.ongetSuperUsersInvalid);
				  objService.setEndpointURL(tibco.admin.util.ServiceHelper.getUserMgtEndpointURL());
				  objService.doCall();
				};

				superUserList.prototype.ongetSuperUsersSuccess = function(objEvent) {
                    var sourceXML = objEvent.target.getInboundDocument();
                    this.mtx.setSourceXML(sourceXML);
                    try{
						var childrenObj = this.mtx.getXML().getChildNodes();
						if(childrenObj.size()==1){
							var records = this.mtx.getXML().selectNodes("//record");
							if(records.size()>0){
								this.mtx.getDescendantOfName("btnMcRemove_24_N").setValueTemplate(valutemplate);
							}
							else{
								this.mtx.getDescendantOfName("btnMcRemove_24_N").setValueTemplate(null);
							}
						}
						else{
							this.mtx.getDescendantOfName("btnMcRemove_24_N").setValueTemplate(null);
						}
					}
					catch(ex)
					{
                             tibco.admin.Main.logException(ex);
                    }
                    this.mtx.repaint();
					
				};

				superUserList.prototype.ongetSuperUsersError = function(objEvent) {
				};

				superUserList.prototype.ongetSuperUsersInvalid = function(objEvent) {
				};

                 
				//============== remove super users ==============================
				/**
				 *	  Remove super users - webservice call
				 */
				superUserList.prototype.callremoveSuperUsers = function(curRowId) {
				  var objService = tibco.admin.Main.loadService("tibco.admin", "tibco/admin/enterpriseAssets/userMgt/window/user/rules/removeSuperUsers.xml", "removeSuperUsers", "Remove Super Users");
				  objService.subscribe(jsx3.net.Service.ON_SUCCESS, this,this.onremoveSuperUsersSuccess);
				  //objService.subscribe(jsx3.net.Service.ON_ERROR, this,this.onremoveSuperUsersError);
				  //objService.subscribe(jsx3.net.Service.ON_INVALID, this,this.onremoveSuperUsersInvalid);
				  objService.userid = this.mtx.getRecordNode(curRowId).getAttribute("dname");
				  objService.setEndpointURL(tibco.admin.util.ServiceHelper.getUserMgtEndpointURL());
				  objService.doCall();
				};

				superUserList.prototype.onremoveSuperUsersSuccess = function(objEvent) {
				  this.callgetSuperUsers();
				};

				superUserList.prototype.onremoveSuperUsersError = function(objEvent) {
				  var myStatus = objEvent.target.getRequest().getStatus();
				  tibco.admin.util.Log.USERMGT.error("Error","The service call failed. The HTTP Status code is: " + myStatus);
				};

				superUserList.prototype.onremoveSuperUsersInvalid = function(objEvent) {
				  tibco.admin.util.Log.USERMGT.error("Invalid","The following message node just failed validation:\n\n" + objEvent.message);
				};




            });
}